//
//  TripViewCell.m
//  XhlTrip
//
//  Created by dllo on 15/8/28.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "TripViewCell.h"
#import "TripModel.h"
#import "UIImageView+WebCache.h"

@implementation TripViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.mage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.mage];
        [_mage release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        
        self.countLabel = [[UILabel alloc] init];
        [self.mage addSubview:self.countLabel];
        [_countLabel release];
        
        
        self.desLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.desLabel];
        self.desLabel.numberOfLines = 2;
        [_desLabel release];
        
        
        self.countLabel.backgroundColor = [UIColor blackColor];
        self.countLabel.alpha = 0.6;
        
        self.countLabel.textAlignment = NSTextAlignmentCenter;
        
         _countLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:12 * Width];
         _desLabel.font = [UIFont fontWithName:@"Verdana-Italic" size:14 * Width];
         _nameLabel.font = [UIFont fontWithName:@"Verdana-Italic" size:18 * Width];
        _countLabel.textColor = [UIColor whiteColor];

    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.mage.frame = CGRectMake(10 * Width, 10 * Height, 130 * Width, 80 * Height);
    self.nameLabel.frame = CGRectMake(150 * Width, 10 * Height, self.contentView.frame.size.width - 150 * Width, 30 * Height);
    
    self.desLabel.frame = CGRectMake(150 * Width, 45 * Height, self.contentView.frame.size.width - 155 * Width, 60 * Height);
    self.countLabel.frame = CGRectMake(0, 57 * Height, self.mage.frame.size.width, 23 * Height);
    
    
}


- (void)setTripModel:(TripModel *)tripModel
{
    if (_tripModel != tripModel) {
        [_tripModel release];
        _tripModel = [tripModel retain];
    }
    
    [self.mage sd_setImageWithURL:tripModel.image_url];
    self.nameLabel.text = tripModel.name;
    NSString *area = [NSString stringWithFormat:@"%@%@", [tripModel.attraction_trips_count stringValue], @" 篇游记" ];
    self.countLabel.text = area;
    self.desLabel.text = tripModel.description_summary;
}

- (void)dealloc
{
    [_tripModel release];
    [_mage release];
    [_desLabel release];
    [_countLabel release];
    [_nameLabel release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
